package huixue.cn.com.rxapp.base;

import android.os.Bundle;
import android.os.Debug;
import android.support.annotation.Nullable;

/**
 * Created by Administrator on 2018/7/28.
 */

public abstract class BaseMVPActivity <P extends BasePresent<V>,V extends IBaseUI> extends BaseCoreActivity  {

    private P presenter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //Debug.startMethodTracing("love_world_");

        presenter = createPresenter();
        presenter.onUIReady(this, getUI());
    }


    protected abstract P createPresenter();

    protected abstract V getUI();

    @Override
    protected void onStart() {
        super.onStart();
        //Debug.stopMethodTracing();
        presenter.onStart();
    }

    @Override
    protected void onResume() {
        super.onResume();
        presenter.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        presenter.onResume();
    }

    @Override
    protected void onStop() {
        super.onStop();
        presenter.onStop();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        presenter.onDestroy();
    }

    public P getPresenter() {
        return presenter;
    }
}
